<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp" %>
<!DOCTYPE HTML>
<html ng-app>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
    <title>${title}</title>
    <%@ include file="/WEB-INF/jsp/commons/meta.jsp" %>
    <link href="${ctx}/resources/new/style.css" type="text/css" rel="stylesheet"/>

</head>
<body>
<form id="inputForm" class="well form-inline" action="${ctx}/adoms/returns/mySave" method="post">
    <input type="hidden" name="id" value="${order.id}"/>
    <input id="type" name="type" type="hidden" value="0"/>
    <table class="table table-striped table-bordered table-condensed">
        <thead>
        <i class="icon-flag"></i>
        <strong>订单表单</strong>
        </thead>
        <tr>
            <td class="span2">退单编号:</td>
            <td>
                <span class="tBlue">${order.code}</span>
                <input id="code" name="code" type="hidden" value="${order.code}" size="30" maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>收货部门:</td>
            <td>
                <span class="tBlue">${order.departmentTarget.name}</span>
                <input id="departmentTarget" name="departmentTarget.id" type="hidden"
                       value="${order.departmentTarget.id}" size="30" maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>商品:</td>
            <td>
                <span class="tBlue">${order.marchandise.name}</span>
                <input id="marchandise" name="marchandise.id" type="hidden" value="${order.marchandise.id}" size="30"
                       maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>单价:</td>
            <td>
				<span class="tBlue">
					￥
					<span id="mPrice" class="tRed">${order.marchandise.price}</span>
					元
				</span>
            </td>
        </tr>
        <tr>
            <td class="span2">退单名称:</td>
            <td>
                <input id="name" class="span4" name="name" type="text" value="${order.name}" size="30" maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>退货数量:</td>
            <td>
                <input id="goodsNumber" class="span1" name="goodsNumber" type="text" value="${order.goodsNumber}"
                       size="30" maxlength="4"/>
                (件)
            </td>
        </tr>
        <tr>
            <td>退货总价:</td>
            <td>
                <input id="totalCost" name="totalCost" class="span2" readonly="readonly" type="text"
                       value="${order.totalCost}" size="30" maxlength="8"/>
                (元)
            </td>
        </tr>
        <tr>
            <td>退单受理人:</td>
            <td>
                <span>${order.orderChargeUser}</span>
                <input id="orderChargeUser" name="orderChargeUser" type="hidden" value="${order.orderChargeUser}"
                       size="30" maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>受理时间:</td>
            <td>
                <span>${order.receivedTime}</span>
                <c:if test="${order.receivedTime != null}">
                    <input datepicker id="receivedTime" name="receivedTime" type="hidden" value="${order.receivedTime}"
                           size="30" maxlength="80"/>
                </c:if>
            </td>
        </tr>
        <tr>
            <td>退单时间:</td>
            <td>
                <span class="tBlue">${order.orderCreateTime}</span>
                <input datepicker id="orderCreateTime" name="orderCreateTime" type="hidden"
                       value="${order.orderCreateTime}" size="30" maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>状态:</td>
            <td>
                <select id="status" name="status">
                    <option value="${order.status}">${order.status.value}</option>
                    <option value="ORDER_HAS_RECEIPT">已收货</option>
                    <option value="ORDER_HAS_CANCELED">已取消</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>退货部门:</td>
            <td>
                <span class="tBlue">${order.department.name}</span>
                <input id="department" name="department.id" type="hidden" value="${order.department.id}" size="30"
                       maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>联系人:</td>
            <td>
                <input id="createUser" name="createUser" type="text" value="${order.createUser}" size="30"
                       maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>联系电话:</td>
            <td>
                <input id="phone" name="phone" type="text" value="${order.phone}" size="30" maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>备注:</td>
            <td>
                <textarea id="memo" name="memo" rows="4" maxlength="200" class="span6">${order.memo}</textarea>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input class="btn btn-primary span1" type="submit" value="提 交"/>
                &nbsp;
                <input class="btn span1 btn-info" type="button" value="返 回" back="back" onclick="history.go(-1)"/>
            </td>
        </tr>
        <tr>
            <td colspan="2" class="hide">
                <input name="memo2" value="${order.memo2 }"/>
                <input name="memo3" value="${order.memo3 }"/>
                <input name="outUser" value="${order.outUser }"/>
                <c:if test="${not empty(order.outTime ) }">
                    <input name="outTime" value="${order.outTime }"/>
                </c:if>
            </td>
        </tr>
    </table>
</form>
<script>
    $(document).ready(function () {
        //为inputForm注册validate函数
        $("#inputForm").validate({
            rules: {
                totalCost: "required",
                phone: "required",
                orderCreateTime: "required",
                status: "required",
                department: "required",
                memo: "required",
                departmentTarget: "required",
                createUser: "required",
                goodsNumber: {
                    required: true,
                    number: true
                }
            }
        });
        //计算总价
        $("#goodsNumber").keyup(function () {
            var number = parseInt($(this).val());
            var price = parseFloat($("#mPrice").html());
            var cost = number * price;
            $("#totalCost").val(cost.toFixed(2));
        });
    });
</script>
</body>
</html>